﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TracNghiemTinHocDaiCuong.ThucThe;
using TracNghiemTinHocDaiCuong.Common;
using TracNghiemTinHocDaiCuong.BIZ;
 

namespace TracNghiemTinHocDaiCuong
{
    public partial class ThemBaiHoc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlChuDe.DataSource = ChuDeBIZ.LayDanhSach();
                ddlChuDe.DataBind();
                ddlMaBaiTiep.DataSource = BaiHocBIZ.LayDanhSach();
                ddlMaBaiTiep.DataBind();
            }
        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            BaiHoc BaiHoc = new BaiHoc();
            BaiHoc.TenBH = txtTenBaiHoc.Text;
            BaiHoc.MaCD = Methods.ConvertNumber(ddlChuDe.SelectedValue);
            BaiHoc.NoiDung = txtNoiDung.Text;
            if (ddlMaBaiTiep.SelectedItem != null)
                BaiHoc.MaBaiTiep = Methods.ConvertNumber(ddlMaBaiTiep.SelectedValue);
            else
                BaiHoc.MaBaiTiep = -1;
            BaiHocBIZ.Them(BaiHoc);
            lblThongBao.Text = "Bạn đã thêm " + txtTenBaiHoc.Text + " thành công";
        }

        protected void btnXoaTuKhoa_Click(object sender, EventArgs e)
        {
            txtTenBaiHoc.Text = "";
            txtNoiDung.Text = "";
        }

        protected void btnQuayLai_Click(object sender, EventArgs e)
        {
            Response.Redirect("QuanLyBaiHoc.aspx");
        }
    }
}